/// <reference path="../typings/index.d.ts" />
/// <reference path="../src/inquiryService.ts" />
/// <reference path="../src/tms.ts" />
describe('getInquiryList',() => {
    var injector:ng.auto.IInjectorService;
    var service:IInquiryService;

    beforeEach(() => {
        injector = angular.injector(['ng','tms']);
        service = injector.get<IInquiryService>('inquiryService');
    });

    //常规无条件导出询价单列表
    it("get inquiryExport normal ",(done) => {
        service.exportList("1",true,"3","4","5","6","7","8","9","10","11",0,10).then((res)=>{
            expect(res.data.total).toBeGreaterThan(0);
            expect(res.data.list.length).toBe(10);
            expect(res.data.extData).toBe("1|true|3|4|5|6|7|8|9|10|11|0|10");
            done();
        },(err) => {
            done.fail(err);
        })
    });

    //获取 总询价编号包含3 的导出查询单列表
    it("get inquiryExport by inquiryid \'3\' ",(done) => {
        service.exportList(null,null,"3",null,null,null,null,null,null,null,null,0,10).then((res)=>{
            expect(res.data.total).toBeGreaterThan(0);
            expect(res.data.list.length).toBe(10);
            expect(res.data.extData).toBe("||3|||||||||0|10");
            done();
        },(err) => {
            done.fail(err);
        })
    });

    //获取 子询价编号包含301 的导出查询单列表
    it("get inquiryExport by inquirychildid \'301\' ",(done) => {
        service.exportList(null,null,null,"301",null,null,null,null,null,null,null,0,10).then((res)=>{
            expect(res.data.total).toBeGreaterThan(0);
            expect(res.data.list.length).toBe(10);
            expect(res.data.extData).toBe("|||301||||||||0|10");
            done();
        },(err) => {
            done.fail(err);
        })
    });

    //获取 客户单位名称包含虾条 的导出查询单列表
    it("get inquiryExport by clientname \'虾条\' ",(done) => {
        service.exportList(null,null,null,null,"虾条",null,null,null,null,null,null,0,10).then((res)=>{
            expect(res.data.total).toBeGreaterThan(0);
            expect(res.data.list.length).toBe(10);
            expect(res.data.extData).toBe("||||虾条|||||||0|10");
            done();
        },(err) => {
            done.fail(err);
        })
    });

    //获取 调度专员编号包含调度专员1 的导出查询单列表
    it("get inquiryExport by userid \'调度专员1\'  ",(done) => {
        service.exportList(null,null,null,null,null,"调度专员1",null,null,null,null,null,0,10).then((res)=>{
            expect(res.data.total).toBeGreaterThan(0);
            expect(res.data.list.length).toBe(10);
            expect(res.data.extData).toBe("|||||调度专员1||||||0|10");
            done();
        },(err) => {
            done.fail(err);
        })
    });

    //获取 发货地址包含北京 ,送货地址包含北京 的导出查询单列表
    it("get inquiryExport by beginaddress \'北京\' and by endaddress \'北京\'  ",(done) => {
        service.exportList(null,null,null,null,null,null,"北京","北京",null,null,null,0,10).then((res)=>{
            expect(res.data.total).toBe(10);
            expect(res.data.list.length).toBe(10);
            expect(res.data.extData).toBe("||||||北京|北京||||0|10");
            done();
        },(err) => {
            done.fail(err);
        })
    });

    //获取 询价状态包含退回下单 的导出查询单列表
    it("get inquiryExport by state \'退回下单\' ",(done) => {
        service.exportList(null,null,null,null,null,null,null,null,"退回下单",null,null,0,10).then((res)=>{
            expect(res.data.total).toBeGreaterThan(0);
            expect(res.data.list.length).toBe(10);
            expect(res.data.extData).toBe("||||||||退回下单|||0|10");
            done();
        },(err) => {
            done.fail(err);
        })
    });

    //获取 开始时间包含2016-09-21 14:46:32 ,结束时间包含2016-09-21 14:45:46 的导出查询单列表
    it("get inquiryExport by begintime \'2016-09-21 14:46:32\' and endtime \'2016-09-21 14:45:46 \' ",(done) => {
        service.exportList(null,null,null,null,null,null,null,null,null,"2016-09-21 14:46:32","2016-09-21 14:45:46",0,10).then((res)=>{
            expect(res.data.total).toBe(10);
            expect(res.data.list.length).toBe(10);
            expect(res.data.extData).toBe("|||||||||2016-09-21 14:46:32|2016-09-21 14:45:46|0|10");
            done();
        },(err) => {
            done.fail(err);
        })
    });

    //获取 排序字段枚举包含2，升序， 总询价编号包含3,子询价编号包含301,客户单位名称包含虾条,调度专员编号包含调度专员1,发货地址包含北京 ,送货地址包含北京,询价状态包含退回下单,开始时间包含2016-09-21 14:46:32 ,结束时间包含2016-09-21 14:45:46 的导出查询单列表
    it("get inquiryExport by begintime \'2016-09-21 14:46:32\' and endtime \'2016-09-21 14:45:46 \' ",(done) => {
        service.exportList('2',true,'3','301','虾条','调度专员1','北京','北京','退回下单',"2016-09-21 14:46:32","2016-09-21 14:45:46",0,10).then((res)=>{
            expect(res.data.total).toBe(10);
            expect(res.data.list.length).toBe(10);
            expect(res.data.extData).toBe("2|true|3|301|虾条|调度专员1|北京|北京|退回下单|2016-09-21 14:46:32|2016-09-21 14:45:46|0|10");
            done();
        },(err) => {
            done.fail(err);
        })
    });
    

    //常规无条件获取
    it('get inquiry list normal',(done) => {
        service.getList(null, null, null, null, null, null, null, null, null, null, null, null, 0, 10).then((res) => {
            expect(res.data.total).toBeGreaterThan(0);
            expect(res.data.list.length).toBe(10);
            expect(res.data.extData).toBe('||||||||||||0|10');
            done();
        },(err) => {
            done.fail(err);
        });
    });

    //获取总询价编号包含160008的询价列表
    it('get inquiry list by inquiryid \'160008\'',(done) => {
        service.getList(null, null, '160008', null, null, null, null, null, null, null, null, null, 0, 10).then((res) => {
            expect(res.data.total).toBeGreaterThan(0);
            expect(res.data.list.length).toBe(10);
            expect(res.data.extData).toBe('||160008||||||||||0|10');
            done();
        },(err) => {
            done.fail(err);
        });
    });

    //获取子询价编号包含801的询价列表
    it('get inquiry list by inquirychildid \'801\'',(done) => {
        service.getList(null, null, null, '801', null, null, null, null, null, null, null, null, 0, 10).then((res) => {
            expect(res.data.total).toBeGreaterThan(0);
            expect(res.data.list.length).toBe(10);
            expect(res.data.extData).toBe("|||801|||||||||0|10");
            done();
        },(err) => {
            done.fail(err);
        });
    });

    //获取客户单位名称包含江苏的询价列表
    it('get inquiry list by clientname \'江苏\'',(done) => {
        service.getList(null, null, null, null, '江苏', null, null, null, null, null, null, null, 0, 10).then((res) => {
            expect(res.data.total).toBeGreaterThan(0);
            expect(res.data.list.length).toBe(10);
            expect(res.data.extData).toBe("||||江苏||||||||0|10");
            done();
        },(err) => {
            done.fail(err);
        });
    });

  //获取调度专员编号为10001的询价列表
    it('get inquiry list by dispatcherid \'10001\'',(done) => {
        service.getList(null, null, null, null, null, '10001', null, null, null, null, null, null, 0, 10).then((res) => {
            expect(res.data.total).toBeGreaterThan(0);
            expect(res.data.list.length).toBe(10);
            expect(res.data.extData).toBe("|||||10001|||||||0|10");
            done();
        },(err) => {
            done.fail(err);
        });
    });

    //获取询价状态为应付报价的询价列表
    it('get inquiry list by states \'应付报价\'',(done) => {
        service.getList(null, null, null, null, null, null, null, null, null, '应付报价', null, null, 0, 10).then((res) => {
            expect(res.data.total).toBeGreaterThan(0);
            expect(res.data.list.length).toBe(10);
            expect(res.data.extData).toBe("|||||||||应付报价|||0|10");
            done();
        },(err) => {
            done.fail(err);
        });
    });
    //获取发货地址包含镇江且送货地址包含天津的询价列表
    it('get inquiry list by beginaddress \'镇江\' and endaddress \'天津\'',(done) =>{
        service.getList(null, null, null, null, null, null, null, '镇江', '天津', null, null, null, 0,10).then((res) => {
            expect(res.data.total).toBeGreaterThan(0);
            expect(res.data.list.length).toBe(10);
            expect(res.data.extData).toBe("|||||||镇江|天津||||0|10");
            done();
        },(err) => {
            done.fail(err);
        });
    });

    //获取下单起始时间为2016.08.21 17:00且下单结束时间为2016.09.03 17:00的询价列表
    it('get inquiry list by begintime \'2016.08.21 17:00\' and endtime \'2016.09.03 17:00\'',(done) =>{
        service.getList(null, null, null, null, null, null, null, null, null, null, '2016.08.21 17:00', '2016.09.03 17:00', 0,10).then((res) => {
            expect(res.data.total).toBeGreaterThan(0);
            expect(res.data.list.length).toBe(10);
            expect(res.data.extData).toBe("||||||||||2016.08.21 17:00|2016.09.03 17:00|0|10");
            done();
        },(err) => {
            done.fail(err);
        });
    });

      //获取详情
   it("get detail",(done) => {
       service.getDetail("1").then((res)=>{
           expect(res.data.urgency).toBe("10");
           expect(res.data.urgencyUnit).toBe("10002");
           expect(res.data.plannerName).toBe("计划专员01");
           expect(res.data.plannerId).toBe("100213");
           expect(res.data.inquiryId).toBe("201613347001");
           expect(res.data.inquiryChildList[0].startProvince).toBe("sample string 1");
           expect(res.data.inquiryChildList[0].startCity).toBe("sample string 2");
           expect(res.data.inquiryChildList[0].startArea).toBe("sample string 3");
           expect(res.data.inquiryChildList[0].startAddress).toBe("sample string 4");
           expect(res.data.inquiryChildList[0].endProvince).toBe("sample string 5");
           expect(res.data.inquiryChildList[0].endCity).toBe("sample string 6");
           expect(res.data.inquiryChildList[0].endArea).toBe("sample string 7");
           expect(res.data.inquiryChildList[0].endAddress).toBe("sample string 8");
           expect(res.data.inquiryChildList[0].plannedArrivalTime).toBe("sample string 9");
           expect(res.data.inquiryChildList[0].plannedDeliveryTime).toBe("sample string 10");
           expect(res.data.inquiryChildList[0].mileage).toBe(1.1);
           expect(res.data.inquiryChildList[0].goodsTypeId).toBe("sample string 11");
           expect(res.data.inquiryChildList[0].goodsTypeName).toBe("sample string 12");
           expect(res.data.inquiryChildList[0].goodsId).toBe("sample string 13");
           expect(res.data.inquiryChildList[0].goodsName).toBe("sample string 14");
           expect(res.data.inquiryChildList[0].goodsQuantity).toBe(15.1);
           expect(res.data.inquiryChildList[0].goodsQuantityUnit).toBe("sample string 16");
           expect(res.data.inquiryChildList[0].carType).toBe("sample string 17");
           expect(res.data.inquiryChildList[0].carLength).toBe("sample string 18");
           expect(res.data.inquiryChildList[0].carrierCategory).toBe("sample string 19");
           expect(res.data.inquiryChildList[0].loadingEffect).toBe("sample string 20");
           expect(res.data.inquiryChildList[0].remarks).toBe("sample string 21");
           expect(res.data.inquiryChildId).toBe("10314956001");
           expect(res.data.dispatchOfficerName).toBe("调度专员01");
           expect(res.data.dispatchOfficerId).toBe("6543211");
           expect(res.data.customerServiceOfficerName).toBe("客服专员01");
           expect(res.data.customerServiceOfficerId).toBe("1123456");
           expect(res.data.createTime).toBe("2016-09-12");
           expect(res.data.content).toBe("总询价备注内容。。。。");
           expect(res.data.consignorPhone).toBe("15050147623");
           expect(res.data.consignorName).toBe("发货员01");
           expect(res.data.consignorId).toBe("100211");
           expect(res.data.clientName).toBe("客户单位01");
           expect(res.data.clientId).toBe("110021");
           expect(res.data.clientCornet).toBe("1203");
           expect(res.data.businessOfficerName).toBe("商务专员01");
           expect(res.data.businessOfficerId).toBe("2011054001");
           expect(res.data.attachmentDetails).toBe("附件备注。。。");
           expect(res.data.attachment.length).toBe(2);
           done();
       },(err) =>{
           done.fail(err);
       });
   });

//添加询价单
it('add inquiryId',(done) =>{
    service.add(10,"10002","2011054001","计划专员01","商务专员01","1123456","客服专员01","6543211","调度专员01","110021","客户单位01","100211","总询价备注内容。。。。",[{
      startProvince: "sample string 1",
      startCity: "sample string 2",
      startArea: "sample string 3",
      startAddress: "sample string 4",
      endProvince: "sample string 5",
      endCity: "sample string 6",
      endArea: "sample string 7",
      endAddress: "sample string 8",
      plannedArrivalTime: "sample string 9",
      plannedDeliveryTime: "sample string 10",
      mileage: 1.1,
      goodsTypeId: "sample string 11",
      goodsTypeName: "sample string 12",
      goodsId: "sample string 13",
      goodsName: "sample string 14",
      goodsQuantity: 15.1,
      goodsQuantityUnit: "sample string 16",
      carType: "sample string 17",
      carLength: "sample string 18",
      carrierCategory: "sample string 19",
      loadingEffect: "sample string 20",
      remarks: "sample string 21"
    }],["sample string 1", "sample string 2"],"附件备注。。。","1203").then((res) =>{
        expect(res.data.extData).toBe("10|10002|2011054001|计划专员01|商务专员01|1123456|客服专员01|6543211|调度专员01|110021|客户单位01|100211|总询价备注内容。。。。|sample string 1|sample string 2|sample string 3|sample string 4|sample string 5|sample string 6|sample string 7|sample string 8|sample string 9|sample string 10|1.1|sample string 11|sample string 12|sample string 13|sample string 14|15.1|sample string 16|sample string 17|sample string 18|sample string 19|sample string 20|sample string 21|2|附件备注。。。|1203");
        done();
    },(err) =>{
        done.fail(err);
        });
});

//获取应付报价列表
it('get pay',(done) =>{
    service.pay('12').then((res) =>{
        expect(res.data.total).toBe(10);
        expect(res.data.extData).toBe("12");
        done();
    },(err) =>{
        done.fail(err);
    });
});

//获取应收报价列表
it('get receive',(done) =>{
    service.receive('12').then((res) =>{
        expect(res.data.receivableQuotation).toBe(1000);
        expect(res.data.receivableQuotationUnit).toBe("元/吨");
        expect(res.data.receivableQuotationDetails).toBe("应收报价说明。。。。");
        done();
    },(err) =>{
        done.fail(err);
    });
});

//变更询价单状态
it('put states',(done) =>{
    service.state("1000169","应付报价","备注解决。。。").then((res) =>{
        expect(res.data.extData).toBe("1000169|应付报价|备注解决。。。");
        done();
    },(err) =>{
        done.fail(err);
    });
});

//变更调度员
it('put dispatch',(done) =>{
    service.dispatch("102648",61031101,"调度专员名称111").then((res) =>{
        expect(res.data.extData).toBe("102648|61031101|调度专员名称111");
        done();
    },(err) =>{
        done.fail(err);
    });
});

//添加询价单应付报价 
it('put addpay',(done) =>{
    service.addPay("102648",110,[
    {
      payableQuotation: "sample string 1",
      payableQuotationUnit: "sample string 2",
      payableQuotationDetails: "sample string 3"
    }],"子询价单备注..12").then((res) =>{
        expect(res.data.extData).toBe("102648|110|sample string 1|sample string 2|sample string 3|子询价单备注..12");
        done();
    },(err) =>{
        done.fail(err);
    });
});

//添加询价单应收报价
it('put addreceive',(done) =>{
    service.addReceive("102648",{receivableQuotation:1000,receivableQuotationUnit:"元/吨",receivableQuotationDetails:"应收报价说明。。。。"},"子询价单备注1238").then((res) =>{
        expect(res.data.extData).toBe("102648|1000|元/吨|应收报价说明。。。。|子询价单备注1238");
        done();
    },(err) =>{
        done.fail(err);
    });
});

//编辑询价单
it('edit inquiryId',(done) =>{
    service.edit("1",5,"10002","2011054001","计划专员019","1123456","客服专员01","6543211","调度专员01","商务专员02","110021","客户单位01","1002119","总询价备注内容2。。。。",[{
      startProvince: "sample string 1",
      startCity: "sample string 2",
      startArea: "sample string 3",
      startAddress: "sample string 4",
      endProvince: "sample string 5",
      endCity: "sample string 6",
      endArea: "sample string 7",
      endAddress: "sample string 8",
      plannedArrivalTime: "sample string 9",
      plannedDeliveryTime: "sample string 10",
      mileage: 1.1,
      goodsTypeId: "sample string 11",
      goodsTypeName: "sample string 12",
      goodsId: "sample string 13",
      goodsName: "sample string 14",
      goodsQuantity: 15.1,
      goodsQuantityUnit: "sample string 16",
      carType: "sample string 17",
      carLength: "sample string 18",
      carrierCategory: "sample string 19",
      loadingEffect: "sample string 20",
      remarks: "sample string 21"
    }],["sample string 1","sample string 2"],"附件备注2。。。","1203").then((res) =>{
        expect(res.data.extData).toBe("1|5|10002|2011054001|计划专员019|1123456|客服专员01|6543211|调度专员01|商务专员02|110021|客户单位01|1002119|总询价备注内容2。。。。|sample string 1|sample string 2|sample string 3|sample string 4|sample string 5|sample string 6|sample string 7|sample string 8|sample string 9|sample string 10|1.1|sample string 11|sample string 12|sample string 13|sample string 14|15.1|sample string 16|sample string 17|sample string 18|sample string 19|sample string 20|sample string 21|2|附件备注2。。。|1203");
        

        done();
    },(err) =>{
        done.fail(err);
        });
});
   
//删除子询价单
it('delete inquiryId',(done) =>{
    service.delete("102648").then((res) =>{
        expect(res.data.extData).toBe("102648");
        done();
    },(err) =>{
        done.fail(err);
    });
});

});



